﻿

(function (win, undefined) {
    //按钮
    //x,y:显示位置, imgs:状态图片
    F5Frame.register("F5Frame", function (cg) {
        this.Button = function () {
            //继承:对象冒充
            this.newMethod = F5Frame.ObjBase; //把_objbase方法赋给newMethod，
            this.newMethod(); //调用newMethod
            delete this.newMethod; //删除newMethod

            //创建按钮
            //x,y:坐标  imgs:图片列表,0,1,2,3表示不同状态
            this.Create = function (x, y, imgs) {
                this._x = x;
                this._y = y;

                this.imgs = imgs;
                this.setImage(this.imgs[0]);
                F5Frame.addGameObject(this);

                //默认可点击
                this.pick();

                return this;
            }

            this.draw_pick = function (context) { }
            //鼠标进入调用事件
            this.pick_in = function () {
                if (this._onpick) {
                    //更新显示状态图片
                    this.setImage(this.imgs[1]);
                    document.body.style.cursor = 'pointer';
                }
                else if (this.drag()) {
                    //可拖动显示移动
                    document.body.style.cursor = 'move';
                }
            }

            //鼠标离开后调用事件
            this.pick_out = function () {
                //更新显示状态图片
                this.setImage(this.imgs[0]);
                document.body.style.cursor = 'default';
            }

            //鼠标按下
            this.on_mousedown = function () {
                //更新显示状态图片
                this.setImage(this.imgs[2]);
            }
            //鼠标起来
            this.on_mouseup = function () {
                //alert("d");
                if (!this._pick)
                    this.pick_out();
                else
                    this.pick_in();
            }
        }
    });

})(window, undefined);